local fudou = fk.CreateSkill({
    name = "sj3__fudou",
  })
  
  Fk:loadTranslationTable{
    ["sj3__fudou"] = "覆斗",
    [":sj3__fudou"] = "出牌阶段，你可以弃置X张牌并发动“<b><a href=':zuilun'>罪论</a></b>”，你因此失去体力后重置“<b>覆斗</b>”并删去一个“<b>罪论</b>”条件。（X为本技能发动次数）",
  
    ["#sj3__fudou_1"] = "你于此回合内造成过伤害",
    ["#sj3__fudou_2"] = "你于此回合内未弃置过牌",
    ["#sj3__fudou_3"] = "手牌数为全场最少",
    ["#sj3__fudou"] = "你可弃置%arg张牌并发动“<b>罪论</b>”",
    ["#sj3__fudou-ask"] = "请移去一条“<b>罪论</b>”",
  
    ["$sj3__fudou1"] = "既作困禽，何妨铤险以覆车？",
    ["$sj3__fudou2"] = "据将覆之巢，必作犹斗之困兽。",
  }
  
  --罪论的代码，把亮牌数量改为参数
  local zuilun_xg = function(name, player, n, self)
    local cg = false
    local room = player.room
    local cards = room:getNCards(3)
    local result = room:askToGuanxing(player, {
      cards = cards,
      area_names = {"Top", "toObtain"},
      top_limit = {3 - n, 3},
      bottom_limit = {n, n},
      skill_name = name,
      skip = true,
    })
    if #result.top > 0 then
      for i = #result.top, 1, -1 do
        table.removeOne(room.draw_pile, result.top[i])
        table.insert(room.draw_pile, 1, result.top[i])
      end
      room:syncDrawPile()
    end
    if #result.bottom > 0 then
      room:moveCardTo(result.bottom, Player.Hand, player, fk.ReasonJustMove, name, nil, false, player)
    else
      local targets = room:getOtherPlayers(player, false)
      local to = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        skill_name = name,
        prompt = "#zuilun-choose",
        cancelable = false,
      })[1]
      room:loseHp(player, 1, name)
      cg = true--失去体力
      if not to.dead then
        room:loseHp(to, 1, name)
      end
    end
    return cg
  end

  fudou:addEffect("active", {
    prompt = function (self, player)
      return "#sj3__fudou:::"..player:usedSkillTimes(fudou.name, Player.HistoryGame)
    end,
    can_use = function(self, player)
      return #player:getCardIds("he") >= player:usedSkillTimes(fudou.name, Player.HistoryGame)--牌不比发动次数少
    end,
    card_filter = function (self,player,to_select,selected)
      local i = player:usedSkillTimes(fudou.name, Player.HistoryGame)
      return (i == 0 and false or (#selected < i)) and not player:prohibitDiscard(to_select)
    end,
    target_filter = Util.FalseFunc,
    feasible = function (self, player, selected, selected_cards)
      return #selected_cards == player:usedSkillTimes(fudou.name, Player.HistoryGame)
    end,
    on_use = function(self, room, effect)
      local player = effect.from
      if #effect.cards > 0 then--弃牌
        room:throwCard(effect.cards,fudou.name,player,player)
      end
      local n = 0
      --造成伤害
      if player:getMark("#sj3__fudou_1") == 0 then
        if #room.logic:getActualDamageEvents(1, function (e)
          return e.data[1].from == player
        end, Player.HistoryTurn) > 0 then
          n = n + 1
        end
      end
      --弃置过牌
      if player:getMark("#sj3__fudou_2") == 0 then
        local events = room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
          for _, move in ipairs(e.data) do
            if move.from == player and move.moveReason == fk.ReasonDiscard and table.find(move.moveInfo, function (info)
              return info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip
            end) then
              return true
            end
          end
        end, Player.HistoryTurn)
        if #events == 0 then
          n = n + 1
        end
      end
      --手牌最少
      if player:getMark("#sj3__fudou_3") == 0 then
        if table.every(room.alive_players, function(p) return p:getHandcardNum() >= player:getHandcardNum() end) then
          n = n + 1
        end
      end

      local zuilun = Fk.skills["zuilun"]
      room:useSkill(player,zuilun,function ()
        if zuilun_xg(zuilun.name,player,n,self) and not player.dead then
          player:setSkillUseHistory(fudou.name,0,Player.HistoryGame)
          local list = {}--失去体力后，移除罪论条件并重置覆斗
          for i = 1, 3, 1 do
            if player:getMark("#sj3__fudou_"..i) == 0 then
              table.insert(list,"#sj3__fudou_"..i)
            end
          end
          if #list > 0 then
            local choice = player.room:askToChoice(player,{
              choices = list,
              skill_name = fudou.name,
              prompt = "#sj3__fudou-ask",
            })
            room:setPlayerMark(player,choice,1)
          end
        end
      end)
    end,
  })

  return fudou